//
//  FRPFullSizePhotoViewModel.m
//  FunctionalReactivePixels
//
//  Created by Linyongzhi on 2017/4/13.
//
//

#import "FRPFullSizePhotoViewModel.h"

#import "FRPPhotoModel.h"

@interface FRPFullSizePhotoViewModel ()

//Privateaccess
@property (nonatomic, assign)NSInteger initialPhotoIndex;

@end

@implementation FRPFullSizePhotoViewModel

@dynamic model;

- (instancetype)initWithPhotoArray:(NSArray *)photoArray initialPhotoIndex:(NSInteger)initialPhotoIndex {
    self = [super initWithModel:photoArray];
    
    if (!self) {
        return nil;
    }
    
    self.initialPhotoIndex = initialPhotoIndex;
    return self;
}

- (NSString *)initialPhotoName {
    return [[self photoModelAtIndex:self.initialPhotoIndex] photoName];
}

- (FRPPhotoModel*)photoModelAtIndex:(NSInteger)index {
    if (index < 0 || index > self.model.count - 1) {
        // Index was out of bounds, return nil
        return nil;
    } else {
        return self.model[index];
    }
}

@end
